/*
 * Copyright (c)  2020,  DataPipeline
 * All rights reserved.
 *
 * Id:SQLParameter.java   2020-07-18 22:26 wanglijun
 */
package cn.datacare.orm.engine;

import static cn.datacare.orm.util.StringUtils.*;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2020
 * </p>
 * <p>
 * Company/Department: DataPipeline
 * </p>
 *
 * @author wanglijun
 * @version 1.0
 * @since 2020-07-18 22:26
 */
public class SQLParameter {


    public static final int NAME_GENERAL = 1;
    public static final int NAME_EXPRESSION = 2;
    public static final int NAME_UN_KNOW = 3;
    private Object value;
    private String expression;
    private int type;
    /**默认为0，不做处理，否则，会将目标对象转成期望的方式插入到数据库，比如long转short ？？*/
    public int jdbcType = 0;

    public SQLParameter(String expression, Object value) {
        this.expression = expression;
        this.value = value;
        this.type = NAME_GENERAL;
    }

    public SQLParameter(Object value) {
        this.value = value;
        this.type = NAME_UN_KNOW;

    }

    public SQLParameter(String expression, Object value, int type) {
        this(expression, value);
        this.type = type;

    }

    @Override
    public String toString() {
        return  value!=null? value.toString(): EMPTY;
    }

    public int getJdbcType() {
        return jdbcType;
    }

    public void setJdbcType(int jdbcType) {
        this.jdbcType = jdbcType;
    }

    public Object getValue(){
        return  this.value;
    }

}
